package com.imodia.checkoo.service.impl;

import java.util.List;

import org.springframework.stereotype.Service;

import com.hsq.commons.util.db.GenericIbatisDao;
import com.hsq.commons.util.db.SqlParam;
import com.hsq.commons.util.db.annotation.SqlSpace;
import com.imodia.checkoo.bean.CmsPageRefColumnsBean;
import com.imodia.checkoo.service.CmsPageRefColumnsService;

@SqlSpace(spaceName="cmspagerefcolumns")
@Service
public class CmsPageRefColumnsServiceImpl 	
	extends
	GenericIbatisDao<CmsPageRefColumnsBean, Integer> implements CmsPageRefColumnsService {
	
	public int saveBatchByPage(List<CmsPageRefColumnsBean> list,int pageId){
		SqlParam sql = new SqlParam();
		sql.andEqualTo("page_id", String.valueOf(pageId));
		delete(sql);
		batchInsert(list);
		return 1;
	}
	
	public int saveBatchByColumns(List<CmsPageRefColumnsBean> list,int catalogueId){
		SqlParam sql = new SqlParam();
		sql.andEqualTo("catalogue_id", String.valueOf(catalogueId));
		delete(sql);
		batchInsert(list);
		return 1;
	}
	
	public List<CmsPageRefColumnsBean> listByPage(int pageId){
		SqlParam sql = new SqlParam();
		sql.andEqualTo("page_id", String.valueOf(pageId));
		return  super.list(sql);
	}
	
}